@startuml UC08_sequence
!theme plain
hide footbox
skinparam sequenceMessageAlign center
skinparam responseMessageBelowArrow true
skinparam BoxPadding 10
autonumber

title UC-08 - Handle missing / invalid / stale obstacle data\n(sequence diagram)

actor "Home user" as User
participant "Obstacle sensors" as Obs
box "Roomba RVC control software\n(inside the SSD black box)" #E8F4FF
  participant "session:\nAutomaticCleaningSession" as Session
  participant "perception:\nObstaclePerceptionContext" as Perception
  participant "navigation:\nNavigationAndEscapeCoordinator" as Nav
  participant "cleaning:\nSurfaceCleaningController" as Clean
end box
participant "Wheel motors\n(left, right)" as Motors
participant "Cleaning hardware" as CleanHW

alt [typical full fault]
  Obs -> Perception : ObstacleStateChanged(invalidOrStale)
  Perception -> Nav : FusedObstacleSnapshot(invalid)
  Nav -> Motors : MotionCommand(stop)
  Nav -> Clean : SuspendCleaningForManeuver()
  Clean -> CleanHW : CleaningCommand(suspend)
else [A1 partial staleness]
  Obs -> Perception : ObstacleStateChanged(partialStale)
  Perception -> Nav : FusedObstacleSnapshot(partialStale)
  Nav -> Motors : MotionCommand(gradualOrPartialStopTBD)
end

alt [typical recovery]
  Obs -> Perception : ObstacleStateChanged(recovered)
  Perception -> Nav : FusedObstacleSnapshot(valid)
  note over Perception, Nav : recovery before UC-02: TBD
else [E1 never recovers]
  note over User : user resets or moves robot
  User -> Session : requestServiceOrReset()
  note over User, Session : hardware / service TBD
end

@enduml
